package com.ziyun.erp.modules.purchase.dao;

import com.baomidou.mybatisplus.plugins.Page;
import com.ziyun.erp.modules.purchase.entity.StorePurchaseApplyEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * 门店采购申请表
 * 
 * @author guizhao
 * @email 
 * @date 2018-09-26 13:28:47
 */
public interface StorePurchaseApplyDao extends BaseMapper<StorePurchaseApplyEntity> {

    List<StorePurchaseApplyEntity> querylistPage(Page<StorePurchaseApplyEntity> page, @Param("map") Map<String,Object> map);

    void updateByMap(@Param("map") Map<String,Object> map, @Param("applyId")Integer applyId);


    List<StorePurchaseApplyEntity> selectAll(@Param("params") Map<String,Object> params);

    @Select("select count(1) from store_purchase_apply where apply_no = #{applyNo} and status in (2,3)")
    int getqueryCountByname(@Param("applyNo") String applyNo);

    @Select("select count(1) from store_purchase_apply where status in (2,3)")
    int getqueryCount();

    @Update("update store_purchase_apply set finance_status = 1 where apply_id = #{applyId} ")
    Integer updateFinase(@Param("applyId") Integer applyId);

    @Update(" update store_purchase_apply set finance_status = 0 where apply_id = #{applyId} ")
    Integer updateFinaseCheck(@Param("applyId") Integer applyId);

    @Update("update store_purchase_apply set finance_status = 2,finance_paytime = now() where apply_id = #{applyId} ")
    Integer updateFinaseCheckOnePay(@Param("applyId") Integer applyId);

    @Update(" update store_purchase_apply set finance_status = 0 where apply_id = #{applyId} ")
    Integer updateFinaseN(@Param("applyId") Integer applyId);


    @Update(" update store_purchase_apply set finance_status = 1 where apply_id in (${sb}) ")
    Integer BatchAuditAll(@Param("sb") StringBuffer sb);


    @Update(" update store_purchase_apply set finance_status = 2 where apply_id in (${sb}) ")
    Integer BulkPaymentAll(@Param("sb") StringBuffer sb);

}
